package com.ruoyi.house.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.house.domain.Result;
import com.ruoyi.house.domain.Sku;
import com.ruoyi.house.service.SkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("spu")
public class SpuController {



    @Autowired
    SkuService skuService;

    @Autowired
    RedisTemplate redisTemplate;



    @RequestMapping("getStockAndPrice")
    public Integer getStockAndPrice(Long id){

        QueryWrapper skuQueryWrapper = new QueryWrapper();

        skuQueryWrapper.eq("spu_id",id);

        List<Sku> skuList = skuService.list(skuQueryWrapper);

        Integer stock = 0;

        for (Sku sku : skuList) {
            QueryWrapper stockQueryWrapper = new QueryWrapper();
            stockQueryWrapper.eq("sku_id",sku.getId());

        }

        return stock;

    }
}
